Skip to main content

TIC80Node Class

Description:

  A class for creating TIC80Node objects.

__call

Type: Metamethod.

Description:

  The constructor function for creating a TIC80Node instance.

Signature:

metamethod __call: function(
self: TIC80NodeClass,
cartFile: string
): TIC80Node | nil

Parameters:

ParameterTypeDescription
cartFilestringThe path to the TIC-80 cart file. It should be a valid TIC-80 cart file (.tic or .png format).
The TIC-80 cart file contains the complete game or program that will run in the TIC-80 virtual machine.
Supported features:
- Full TIC-80 API support (drawing, sound, input, etc.).
- Keyboard, controller, and touch input handling.
- Audio playback through the TIC-80 sound engine.
- Runs at TIC-80's native resolution (240x136 pixels).
- Fixed frame rate matching TIC-80's specification (60 FPS).

Returns:

Return TypeDescription
TIC80Node | nilThe created TIC80Node instance. If creation fails, returns nil.

__call

Type: Metamethod.

Description:

  The constructor function for creating a TIC80Node instance with code from a file and resources from a cart file.

Signature:

metamethod __call: function(
self: TIC80NodeClass,
resourceCartFile: string,
codeFile: string
): TIC80Node | nil

Parameters:

ParameterTypeDescription
resourceCartFilestringThe path to the TIC-80 cart file containing art and audio resources (.tic or .png format).
codeFilestringThe path to the code file (e.g., .lua, .yue).

Returns:

Return TypeDescription
TIC80Node | nilThe created TIC80Node instance. If creation fails, returns nil.

codeFromCart

Type: Function.

Description:

  Extracts code text from a TIC-80 cart file.

Signature:

codeFromCart: function(self: TIC80NodeClass, cartFile: string): string

Parameters:

ParameterTypeDescription
cartFilestringThe path to the TIC-80 cart file (.tic or .png format).

Returns:

Return TypeDescription
stringThe extracted code text, or empty string if failed.

mergeTic

Type: Function.

Description:

  Merges resource cart and code file into a .tic cart file.

Signature:

mergeTic: function(self: TIC80NodeClass, outputFile: string, resourceCartFile: string, codeFile: string): boolean

Parameters:

ParameterTypeDescription
outputFilestringThe path to save the merged .tic cart file.
resourceCartFilestringThe path to the resource cart file.
codeFilestringThe path to the code file.

Returns:

Return TypeDescription
booleanTrue if successful, false otherwise.

mergePng

Type: Function.

Description:

  Merges PNG cover, resource cart, and optional code file into a .png cart file.

Signature:

mergePng: function(self: TIC80NodeClass, outputFile: string, coverPngFile: string, resourceCartFile: string, codeFile?: string): boolean

Parameters:

ParameterTypeDescription
outputFilestringThe path to save the merged .png cart file.
coverPngFilestringThe path to the cover PNG image file.
resourceCartFilestringThe path to the resource cart file.
codeFilestring[optional] Path to the code file. If empty, uses code from resource cart.

Returns:

Return TypeDescription
booleanTrue if successful, false otherwise.